package com.rover022.flixelgame.world.displayobject
{
	import com.greensock.loading.ImageLoader;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.Event;
	
	import org.flixel.FlxSprite;
	
  
	/**
	 * 1加载类型的 FlxSprite
	 * 2直接设置bitmapdata图片
	 * @author Administrator
	 * 
	 */
	public class FlxLoadImage extends FlxBaseSprite
	{
		
		public function FlxLoadImage( )
		{

		}
		
		public function setImageUrl(url:String):void
		{
			var imageLoader:ImageLoader = new ImageLoader(url);
			imageLoader.addEventListener(Event.COMPLETE,completeHandle);
			imageLoader.autoDispose=true;
			imageLoader.load();
		}
		
		public function setBitmapData(src:BitmapData):void
		{
			pixels = src;
			
		}
		
		
		protected function completeHandle(event:Event):void
		{
			var imageLoader:ImageLoader = event.currentTarget as ImageLoader;
			pixels = (imageLoader.rawContent as Bitmap).bitmapData;
		}
	}
}